import 'package:flutter/services.dart';

class ClipboardUtils {
  ClipboardUtils._();

  /// 复制文字到剪切板
  static Future<bool> copy(String text) async {
    if (text.isNotEmpty && text.length > 0) {
      await Clipboard.setData(ClipboardData(text: text));
      return true;
    }
    return false;
  }

  /// 粘贴
  static Future<String?> get paste async {
    final ClipboardData? data = await Clipboard.getData(Clipboard.kTextPlain);
    if (data != null && data.text != null) {
      return data.text;
    }
    return null;
  }
}
